﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExamEdit.aspx.cs" Inherits="YiShi.Exam.ExamEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" href="/css/redmond/common.css" type="text/css" media="all" />
    <link rel="stylesheet" href="/css/redmond/jquery-ui-1.8.18.custom.css" type="text/css"
        media="all" />

    <script type="text/javascript" src="/scripts/jquery-1.7.1.min.js"></script>

    <script type="text/javascript" src="/scripts/jquery-ui-1.8.18.custom.min.js"></script>

    <script type="text/javascript" src="/scripts/common.js"></script>

</head>
<body style="font-size: 9pt;">
    <div align="center">
        <table id="MainTable" style="width: 600px">
            <tr style="border: 1px solid #c5dbec; background-color: #f5f8f9">
                <td colspan="4" align="left">
                    <font style="font-size: 11pt; font-weight: bold">试卷编辑</font>
                </td>
            </tr>
            <tr>
                <td width="20%" align="center" style="background-color: #d0e5f5;">
                    名称
                </td>
                <td width="30%" align="left">
                    <input name="Id" value="<%=id %>" type="hidden">
                    <input name="Name" style="width: 100px;" value="<%=name %>" notallowempty="true">
                </td>
                <td width="20%" align="center" style="background-color: #d0e5f5;">
                </td>
                <td width="30%" align="left">
                </td>
            </tr>
            <tr style="border: 1px solid #c5dbec; background-color: #f5f8f9">
                <td colspan="4" align="center">
                    <%=buttonHtml %>&nbsp;
                    <button id='CancelButton'>
                        取消</button>
                </td>
            </tr>
        </table>

        <script language="javascript">
            var actionType = "<%=returnActionType %>";
            $(function event() {
                //Init
                $("button").button();
                switch (actionType.toLowerCase()) {
                    case "delete":
                    case "view":
                        var $table = $("#MainTable");
                        var eles = $table.find("[name]");
                        for (var i = 0; i < eles.length; i++)
                            $(eles[i]).attr("disabled", true);
                        break;
                }
                $("#CancelButton").click(function() {
                    window.close();
                });
                if (actionType.toLowerCase() != "view")
                    $("#UpdateButton").click(function() {
                        var jsondata = {};
                        switch (actionType.toLowerCase()) {
                            case "insert":
                            case "update":
                            case "delete":
                                var $table = $("#MainTable");
                                var eles = $table.find("[name]");
                                for (var i = 0; i < eles.length; i++) {
                                    var name = $(eles[i]).attr("name");
                                    var value = $.trim($(eles[i]).val());
                                    if ($(eles[i]).attr("notallowempty") == "true" && value == "") {
                                        alert("字段[" + name + "]不允许为空！");
                                        return;
                                    }
                                    jsondata[name] = value;
                                }
                                break;
                        }
                        jsondata["ActionType"] = actionType;
                        $.post("ExamEdit.aspx", jsondata, function(data) {
                            if (data.IsSuccess == "true") {
                                var msg = "";
                                switch (actionType.toLowerCase()) {
                                    case "insert":
                                        msg = "新增成功！";
                                        break;
                                    case "update":
                                        msg = "修改成功！";
                                        break;
                                    case "delete":
                                        msg = "删除成功！";
                                        break;
                                }
                                Alert(msg, function() {
                                    window.opener.Jump({ data: { ActionType: "Jump"} });
                                    window.close();
                                });
                            }
                            else
                                ShowError(data.Message, data.Source, data.StackTrace);
                            HideMask();
                        }, "json");
                    });

            });
        </script>

    </div>
</body>
</html>
